<template>
  <div class="topic">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <ul class="list">
        <router-link
          tag="li"
          class="item"
          v-for="item in list"
          :key="item.id"
          :to="`/topic/topicdetail?id=${item.id}`"
        >
          <img :src="item.scene_pic_url" alt="" />
          <p class="title">{{ item.title }}</p>
          <p class="subtitle">{{ item.subtitle }}</p>
          <p class="price">{{ item.price_info }}元起</p>
        </router-link>
      </ul>
    </van-list>
  </div>
</template>
<script>
import { listaction } from "@/api/topic/index";
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1,
    };
  },
  methods: {
    onLoad() {
      // 异步更新数据
      this.getList();
    },
    async getList() {
      const { data, total } = await listaction({
        page: this.page,
      });
      this.list.push(...data);
      this.loading = false;
      this.page++;
      if (this.page > total) {
        this.finished = true;
      }
    },
  },
};
</script>
<style lang="scss">
@import "./index.scss";
</style>
